/**
 * 
 */
package numbers;

import java.math.BigInteger;

/**
 * @author lnunno
 *
 */
public class ByteExample {
	/**
	 * Merges two bytes into a short.
	 * @param upperBits upper bits of the number.
	 * @param lowerBits lower bits of the number.
	 * @return
	 */
	public int mergeToInt(byte upperBits, byte lowerBits){
		return (short) ( (upperBits << 8) | (lowerBits & 0xFF) );
	}
	
	public void run(){
		byte[] boo = {0x15};
		System.out.println("Byte min = " + Byte.MIN_VALUE + "( " + Integer.toBinaryString(Byte.MIN_VALUE)+" )"  
				+  "( " + "0x"+Integer.toHexString(Byte.MIN_VALUE) + " )"
				+ "\n"
				+ "  Byte max = " + Byte.MAX_VALUE + 
				"( "  + Integer.toBinaryString(Byte.MAX_VALUE) + " )"
				+ "( " + "0x"+Integer.toHexString(Byte.MAX_VALUE) + " )");
		BigInteger big = new BigInteger(boo);
		System.out.println(big.toString(2));
		
		byte[] merg = { 20, 7 };
		BigInteger bi = new BigInteger(merg);
		System.out.println(bi.toString(2));
		System.out.println(10 << 8);
		int conv = mergeToInt(merg[0], merg[1]);
		System.out.println(conv);
	}
	
	public static void main(String[] args){
		ByteExample be = new ByteExample();
		be.run();
	}
}
